import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class Demo15{
    public static void main(String[] args) {
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url="jdbc:mysql://localhost:3306/demo?serverTimezone=GMT&useSSL=false";
            String user="root";
            String password="1015";
            Connection connection= DriverManager.getConnection(url,user,password);
            String sql="insert into demo(name,password,address) values (?,?,?)";
            PreparedStatement preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1,"赵六");
            preparedStatement.setString(2,"zhaoliu");
            preparedStatement.setString(3,"湖北襄阳");
            int rows = preparedStatement.executeUpdate();
            System.out.println("影响了数据库表"+rows+"条数据");
            preparedStatement.close();
            connection.close();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}